<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context 
                           http://www.springframework.org/schema/context/spring-context.xsd">

	<!-- Define the controllers using annotations -->
    <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
	<context:component-scan base-package="de.hdu.pms.ho.ctrl"/>
	
	
	<!-- ******************* -->
	<!-- DB and Hibernate    -->
	<!-- ******************* -->
	
    <bean class="de.hdu.pms.ho.Startup" id="init" init-method="initDB">
		<property name="driverClass" value="com.mysql.jdbc.Driver" />
		<property name="user" value="root" />
		<property name="password" value="" />
		<property name="defaultDBurl" value="jdbc:mysql://localhost:3306/mysql" />
		<property name="newDB" value="hotelorganizer" />
    </bean>
    
	<bean id="dataSource"
		class="com.mchange.v2.c3p0.ComboPooledDataSource"
		depends-on="init">
		<property name="driverClass" value="com.mysql.jdbc.Driver" />
		<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/hotelorganizer" />
		<property name="user" value="root" />
		<property name="password" value="" />
		<property name="minPoolSize" value="2" />
      	<property name="maxPoolSize" value="4" />
	</bean>
	
	<bean id="hibernateSessionFactory"
		class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="annotatedClasses">
			<list>
				<value>de.hdu.pms.ho.model.Zimmer</value>
				<value>de.hdu.pms.ho.model.Personal</value>
				<value>de.hdu.pms.ho.model.Kategorie</value>
				<value>de.hdu.pms.ho.model.Kunde</value>
				<value>de.hdu.pms.ho.model.Arbeitsplan</value>
				<value>de.hdu.pms.ho.model.ZimmerKunde</value>
				<!-- <value>de.hdu.pms.ho.model.ZimmerKategorie</value> -->
			</list>
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
				<prop key="hibernate.hbm2ddl.auto">update</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
			</props>
		</property>
	</bean>



			
	<!-- ******************* -->
	<!-- Data Access Objects -->
	<!-- ******************* -->
	
	<!-- Bean für Personal- Dominic -->
	<bean id="personalDao" class="de.hdu.pms.ho.dao.PersonalDao">
		<property name="sessionFactory" ref="hibernateSessionFactory"/>
	</bean>
	
	<!-- Bean für Zimmer- Helena -->	
	<bean id="zimmerDao" class="de.hdu.pms.ho.dao.ZimmerDao">
		<property name="sessionFactory" ref="hibernateSessionFactory"/>
	</bean>
	
	<!-- Bean für Kunde - Hendrik -->
	<bean id="kundeDao" class="de.hdu.pms.ho.dao.KundeDao">
		<property name="sessionFactory" ref="hibernateSessionFactory"></property>
	</bean>
	
	<!-- Bean für Kategorie - Thomas -->
	<bean id="kategorieDao" class="de.hdu.pms.ho.dao.KategorieDao">
		<property name="sessionFactory" ref="hibernateSessionFactory"/>
	</bean>
	
	<!-- Bean für Zimmerkategorie - Helena -->
<!--  	 <bean id="zimmerKategorieDao" class="de.hdu.pms.ho.dao.ZimmerKategorieDao">  -->
<!--  		<property name="sessionFactory" ref="hibernateSessionFactory"/>  -->
<!-- 	</bean>   -->
	
	<!-- Bean für Arbeitsplan - Helena -->
	<bean id="arbeitsplanDao" class="de.hdu.pms.ho.dao.ArbeitsplanDao">
		<property name="sessionFactory" ref="hibernateSessionFactory"/>
	</bean>
	
	<!-- Bean für ZimmerKunde - Dominic -->
	<bean id="zimmerKundeDao" class="de.hdu.pms.ho.dao.ZimmerKundeDao">
		<property name="sessionFactory" ref="hibernateSessionFactory"/>
		
	</bean>
	
	
		
	<!-- ******************* -->
	<!-- Controllers         -->
	<!-- ******************* -->
	

	
	<!-- Bean für Personal- Dominic -->
	<bean id="personalController" class="de.hdu.pms.ho.ctrl.PersonalController">
		<property name="personalDao" ref="personalDao"/>
	</bean>
	
	<!-- Bean für Zimmer- Helena -->	
	<bean id="zimmerController" class="de.hdu.pms.ho.ctrl.ZimmerController">
		<property name="zimmerDao" ref="zimmerDao"/>
		<property name="kategorieDao" ref="kategorieDao"/>
	</bean>
	
	<!-- Bean für Kunde - Hendrik -->
	<bean id="kundeController" class="de.hdu.pms.ho.ctrl.KundeController">
		<property name="kundeDao" ref="kundeDao"></property>
	</bean>
	
	<!-- Bean für Kategorie - Thomas -->
	<bean id="kategorieController" class="de.hdu.pms.ho.ctrl.KategorieController">
		<property name="kategorieDao" ref="kategorieDao"/>
	</bean>
	
	<!-- Bean für Arbeitsplan - Helena -->
  	<bean id="arbeitsplanController" class="de.hdu.pms.ho.ctrl.ArbeitsplanController">  
		<property name="arbeitsplanDao" ref="arbeitsplanDao"/> 
		 <property name="personalDao" ref="personalDao"/>
		<property name="zimmerDao" ref="zimmerDao"/>
	</bean> 
	
	<!-- Bean für ZimmerKategorie - Helena -->
<!--   	<bean id="zimmerKategorieController" class="de.hdu.pms.ho.ctrl.ZimmerKategorieController">   -->
<!-- 		<property name="zimmerKategorieDao" ref="zimmerKategorieDao"/>  -->
<!-- 		<property name="zimmerDao" ref="zimmerDao"/> -->
<!-- 		<property name="kategorieDao" ref="kategorieDao"/>  -->
<!-- 	</bean> -->
	
	<!-- Bean für ZimmerKundeController - Dominic --> 
  	<bean id="zimmerKundeController" class="de.hdu.pms.ho.ctrl.ZimmerKundeController">  
		<property name="zimmerKundeDao" ref="zimmerKundeDao"/>
		<property name="kundeDao" ref="kundeDao"/>
		<property name="zimmerDao" ref="zimmerDao"/>		 
	</bean> 
	
	<!-- ******************* -->
	<!-- Views               -->
	<!-- ******************* -->	
	
	<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/view/" />
		<property name="suffix" value=".jsp" />
	</bean>
</beans>